from sqlalchemy import Column, Integer, String, Float, DateTime
from source.entity.Base import Base

class CeilometerMetrics(Base):
    __tablename__ = 'ceilometer_metrics'
    nedn = Column(String, primary_key=True)
    granularity = Column(String, primary_key=True)
    begintime = Column(DateTime, primary_key=True)
    endtime = Column(DateTime, primary_key=True)
    cpuusageatio = Column(Float, nullable=True)
    memoryusageratio = Column(Float, nullable=True)
    diskreadbytes = Column(Float, nullable=True)
    diskwritebytes = Column(Float, nullable=True)
    networkincomingbytes = Column(Float, nullable=True)
    networkoutgoingbytes = Column(Float, nullable=True)
    alarmnums  = Column(Integer, nullable=True)

    def __init__(self,nedn, granularity, begintime, endtime, cpuusageatio, memoryusageratio, diskreadbytes, diskwritebytes, networkincomingbytes, networkoutgoingbytes, alarmnums):
        self.nedn = nedn
        self.granularity = granularity
        self.begintime = begintime
        self.endtime = endtime
        self.cpuusageatio = cpuusageatio
        self.memoryusageratio = memoryusageratio
        self.diskreadbytes = diskreadbytes
        self.diskwritebytes = diskwritebytes
        self.networkincomingbytes = networkincomingbytes
        self.networkoutgoingbytes = networkoutgoingbytes
        self.alarmnums = alarmnums

    def __repr__(self):
        return '<CeilometerMetrics %r>' % [self.nedn, self.granularity, self.begintime, self.endtime, self.cpuusageatio]
